package com.itrus.cert;

import com.itrus.util.CertUtils;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.cert.CRLException;
import java.util.Date;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.x509.CertificateList;
import org.bouncycastle.jce.provider.X509CRLObject;
import org.bouncycastle.util.encoders.Base64;

public class X509CRL extends X509CRLObject
{
  public X509CRL(CertificateList paramCertificateList)
    throws CRLException
  {
    super(paramCertificateList);
  }

  public static X509CRL engineGenerateCRL(InputStream paramInputStream)
    throws CRLException
  {
    if (!paramInputStream.markSupported())
      paramInputStream = new BufferedInputStream(paramInputStream);
    try
    {
      paramInputStream.mark(10);
      if (paramInputStream.read() != 48)
      {
        paramInputStream.reset();
        return readPEMCRL(paramInputStream);
      }
      paramInputStream.reset();
      X509CRL localX509CRL = readDERCRL(paramInputStream);
      return localX509CRL;
    }
    catch (Exception localException)
    {
      throw new CRLException(localException.toString());
    }
  }

  public static X509CRL getInstance(InputStream paramInputStream)
    throws CRLException
  {
    return engineGenerateCRL(paramInputStream);
  }

  public static X509CRL getInstance(String paramString)
    throws CRLException
  {
    return engineGenerateCRL(new ASN1InputStream(paramString.getBytes()));
  }

  public static X509CRL getInstance(java.security.cert.X509CRL paramX509CRL)
    throws CRLException
  {
    return getInstance(paramX509CRL.getEncoded());
  }

  public static X509CRL getInstance(byte[] paramArrayOfByte)
    throws CRLException
  {
    return engineGenerateCRL(new ASN1InputStream(paramArrayOfByte));
  }

  public static X509CRL getInstanceFromFile(String paramString)
    throws FileNotFoundException, CRLException
  {
    return engineGenerateCRL(new FileInputStream(paramString));
  }

  public static X509CRL getInstanceFromURL(String paramString)
    throws IOException, CRLException
  {
    HttpURLConnection localHttpURLConnection = null;
    try
    {
      localHttpURLConnection = (HttpURLConnection)new URL(paramString).openConnection();
      localHttpURLConnection.addRequestProperty("User-agent", "Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1)");
      X509CRL localX509CRL = getInstance(localHttpURLConnection.getInputStream());
      return localX509CRL;
    }
    finally
    {
      localHttpURLConnection.disconnect();
    }
  }

  private static X509CRL readDERCRL(InputStream paramInputStream)
    throws IOException, CRLException
  {
    return new X509CRL(new CertificateList((ASN1Sequence)new ASN1InputStream(paramInputStream).readObject()));
  }

  private static String readLine(InputStream paramInputStream)
    throws IOException
  {
    StringBuffer localStringBuffer = new StringBuffer();
    while (true)
    {
      int i = paramInputStream.read();
      if ((i == 10) || (i < 0))
      {
        if ((localStringBuffer.length() != 0) || (i >= 0))
          break;
        return null;
      }
      if (i != 13)
        localStringBuffer.append((char)i);
    }
    return localStringBuffer.toString();
  }

  private static X509CRL readPEMCRL(InputStream paramInputStream)
    throws IOException, CRLException
  {
    StringBuffer localStringBuffer = new StringBuffer();
    while (true)
    {
      String str = readLine(paramInputStream);
      if (str == null)
      {
        if (localStringBuffer.length() == 0)
          break;
        return readDERCRL(new ByteArrayInputStream(Base64.decode(localStringBuffer.toString())));
      }
      if ((!str.equals("-----BEGIN CRL-----")) && (!str.equals("-----BEGIN X509 CRL-----")) && (!str.equals("-----END CRL-----")) && (!str.equals("-----END X509 CRL-----")))
        localStringBuffer.append(str);
    }
    return null;
  }

  public String getIssuerDNString()
  {
    return CertUtils.getX509NameString(getIssuerX500Principal());
  }

  public boolean isOnValidPeriod()
  {
    Date localDate1 = getThisUpdate();
    Date localDate2 = getNextUpdate();
    Date localDate3 = new Date();
    return (!localDate3.before(localDate1)) && (!localDate3.after(localDate2));
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.itrus.cert.X509CRL
 * JD-Core Version:    0.6.2
 */